package com.ruoyi.system.navigationMark.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.navigationMark.domain.NavigationMark;
import com.ruoyi.system.navigationMark.service.INavigationMarkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 航标基础信息Controller
 * 
 * @author ruoyi
 * @date 2025-11-21
 */
@RestController
@RequestMapping("/system/navigationMark")
public class NavigationMarkController extends BaseController
{
    @Autowired
    private INavigationMarkService navigationMarkService;

    /**
     * 查询航标基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:navigationMark:list')")
    @GetMapping("/list")
    public TableDataInfo list(NavigationMark navigationMark)
    {
        startPage();
        List<NavigationMark> list = navigationMarkService.selectNavigationMarkList(navigationMark);
        return getDataTable(list);
    }

    /**
     * 导出航标基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:navigationMark:export')")
    @Log(title = "航标基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NavigationMark navigationMark)
    {
        List<NavigationMark> list = navigationMarkService.selectNavigationMarkList(navigationMark);
        ExcelUtil<NavigationMark> util = new ExcelUtil<NavigationMark>(NavigationMark.class);
        util.exportExcel(response, list, "航标基础信息数据");
    }

    /**
     * 获取航标基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:navigationMark:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(navigationMarkService.selectNavigationMarkById(id));
    }

    /**
     * 新增航标基础信息
     */
    @PreAuthorize("@ss.hasPermi('system:navigationMark:add')")
    @Log(title = "航标基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NavigationMark navigationMark)
    {
        return toAjax(navigationMarkService.insertNavigationMark(navigationMark));
    }

    /**
     * 修改航标基础信息
     */
    @PreAuthorize("@ss.hasPermi('system:navigationMark:edit')")
    @Log(title = "航标基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NavigationMark navigationMark)
    {
        return toAjax(navigationMarkService.updateNavigationMark(navigationMark));
    }

    /**
     * 删除航标基础信息
     */
    @PreAuthorize("@ss.hasPermi('system:navigationMark:remove')")
    @Log(title = "航标基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(navigationMarkService.deleteNavigationMarkByIds(ids));
    }


    /**
     * 查询部门下航标
     */
    @PreAuthorize("@ss.hasPermi('system:buoy:list')")
    @GetMapping("/deptNavigationMarkList")
    public AjaxResult deptNavigationMarkList(String markName){
        return AjaxResult.success(navigationMarkService.deptNavigationMarkList(markName));
    }
}
